extends Area2D
class_name abstract_input_button

## open door n times
#var open_n: int = 8

## object of input button, for example red button: object = "red"
var object = "void"
## input button press state
var pressed: bool
## asaka stay on button
var asaka_stays: bool
## texture when button is active, only rectangle
var active_texture
# Called when the node enters the scene tree for the first time.
func _ready():
	pass
	#if pressed:
	#	modulate += Color(1, 1, 1, 0)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
	if Input.is_action_just_pressed("place") and asaka_stays and not GlobalVar.mouse_input_lock and not pressed:
		if GlobalVar.exit_inventory[GlobalVar.exit_slot] == object:
			pressed = true 
			$Sprite2D.texture = active_texture
			print("Pressed state: ", pressed)
			GlobalVar.exit_door_open = true
#			open_door()
		else:
			push_error("Invalid button object") ## printerr()

func _on_body_entered(_body):
	asaka_stays = true
	print("asaka_stays: ", asaka_stays)

func _on_body_exited(_body):
	asaka_stays = false
	print("asaka_stays: ", asaka_stays)

#func open_door():
	#GlobalVar.exit_door_open = true
	#open_n -= 1
	#if open_n > 0:
		#$Timer.start()
#
#
#func _on_timer_timeout():
	#open_door()
